#include <iostream>
#include <string>
#include <cmath>

using namespace std;

bool is_prime(int num) {
    if (num <= 1) {
        return false;
    }
    for (int i = 2; i <= sqrt(num); ++i) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    string words[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
    string input;
    getline(cin, input);

    int n = 0;
    for (int i = 0; i < 3; ++i) {
        int word_index = -1;
        for (int j = 0; j < 10; ++j) {
            if (words[j] == input.substr(i * 5, 4)) {
                word_index = j;
                break;
            }
        }
        if (word_index == -1) {
            cout << "Wrong input" << endl;
            return 0;
        }
        n = n * 10 + word_index;
    }

    if (n < 100 || n > 999) {
        cout << "Wrong input" << endl;
        return 0;
    }

    int next_prime = n;
    while (true) {
        if (is_prime(next_prime)) {
            cout << next_prime << endl;
            break;
        }
        ++next_prime;
    }

    return 0;
}
